/*
 * Protocolo.h
 *
 *  Created on: 08/12/2013
 *      Author: gonzalo
 */

#ifndef PROTOCOLO_H_
#define PROTOCOLO_H_

#include "../channel_common/ChannelCommon.h"

#define COLA_SERVICIOS_PATH "/tmp/colaservicios"
#define COLA_SERVICIOS_KEY  'a'

#define TAM_PDU_CAPAN ( TAM_PDU_CANAL - TAM_HEADER_CANAL )
#define TAM_HEADER_CAPAN ( 2 * sizeof(int) )
#define TAM_PAYLOAD_CAPAN ( TAM_PDU_CAPAN - TAM_HEADER_CAPAN )

#define TAM_HEADER_MQ ( 2 * sizeof(int) )
#define TAM_PDU_MQ ( TAM_PAYLOAD_CAPAN  - TAM_HEADER_MQ )
#define TAM_PAYLOAD_MQ ( TAM_PDU_MQ - sizeof(long) - sizeof(int))

#include <string.h>

/* Capa N - Servicios */
typedef struct _payload_mq {
	long mtype;
	int size;
	char data[TAM_PAYLOAD_MQ];
} PayloadServicioMensajes;

typedef struct _pdu_mq {
	int UidColaDestino;
	int size;
	PayloadServicioMensajes payloadMq;
} PDUServicioMensajes;


typedef struct _payload_servicios {
	char data[TAM_PAYLOAD_CAPAN];

	_payload_servicios(){}

	_payload_servicios(PDUServicioMensajes& pdu) {
		memcpy((void*)&this->data, (void*)&pdu, TAM_PAYLOAD_CAPAN);
	}

} PayloadCapaServicios;

typedef struct _PDUCapaServicios {
	int tipo;
	int size;
	PayloadCapaServicios payload;
} PDUCapaServicios;

#endif /* PROTOCOLO_H_ */
